package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.ConsultVO;
import com.digitalchina.lxnsy.interfaces.ICallBackPos;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/7/17 11:10
 * 修改备注：
 * ================================================
 */

public class MyReplyListHolder extends BaseViewHolder<ConsultVO> {

    private TextView tvNameConsult;
    private TextView tvNameReply;
    private TextView tvTimeConsult;
    private TextView tvTimeReply;
    private TextView tvConsult;
    private TextView tvReply;
    private TextView tvTitle;
    private TextView tvReplyBtn;
    private SimpleDraweeView sdv;
    private ICallBackPos iCallBackPos;


    public MyReplyListHolder(ViewGroup parent, ICallBackPos iCallBackPos) {
        super(parent, R.layout.item_my_reply_list);
        tvNameConsult = $(R.id.tv_name_consult);
        tvNameReply = $(R.id.tv_name_reply);
        tvTimeConsult = $(R.id.tv_time_consult);
        tvTimeReply = $(R.id.tv_time_reply);
        tvConsult = $(R.id.tv_consult);
        tvReply = $(R.id.tv_reply);
        tvReplyBtn = $(R.id.tv_reply_btn);

        sdv = $(R.id.sdv);
        tvTitle = $(R.id.tv_title);

        this.iCallBackPos = iCallBackPos;
    }

    @Override
    public void setData(ConsultVO data) {
        super.setData(data);


        if (data.getInstance() != null && data.getInstance().getProductImageList() != null && data.getInstance().getProductImageList().size() > 0)
            FrescoUtil.showImageMid(data.getInstance().getProductImageList().get(0).getImage(), sdv);
        else
            FrescoUtil.setDefaultImage(sdv);

        tvTitle.setText(data.getInstance().getName() + "");
        //replyStatus:回复状态 0-待回复  1-已回复

        if(data.getReplyStatus()==1){
            tvConsult.setText(data.getConsultContent());
            tvNameConsult.setText(data.getConsultMen().getMobilePhone());
            tvTimeConsult.setText(data.getConsultTime() + "");

            tvReply.setText(data.getReplyContent());
            tvNameReply.setText(data.getReplyMen().getMobilePhone());
            tvTimeReply.setText(data.getReplyTime() + "");

            tvReply.setVisibility(View.VISIBLE);
            tvNameReply.setVisibility(View.VISIBLE);
            tvTimeReply.setVisibility(View.VISIBLE);
            tvReplyBtn.setVisibility(View.GONE);
        }else{
            tvConsult.setText(data.getConsultContent());
            tvNameConsult.setText(data.getConsultMen().getMobilePhone());
            tvTimeConsult.setText(data.getConsultTime() + "");

            tvReply.setVisibility(View.GONE);
            tvNameReply.setVisibility(View.GONE);
            tvTimeReply.setVisibility(View.GONE);
            tvReplyBtn.setVisibility(View.VISIBLE);

            tvReplyBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    iCallBackPos.clickOk(getAdapterPosition());
                }
            });
        }
    }

}
